﻿using System;
using System.Collections.Generic;
using System.Data.SqlTypes;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace ZJF.GenericTech._03_泛型基础
{
    internal class Stack<T>
    {
        private T[] storage;
        private int index;
        private int capacity=10;

        public Stack() { 
            this.storage = new T[10];
            this.index = 0;
        }

        public void Push(T item) {
            if (this.storage.Length < this.capacity)
            {
                this.storage[index] = item;
                this.index++;
            }
            else {
                throw new Exception("stack is full");
            }
            
        }

        public T Pop() {
            if (this.storage.Length <= 0)
            {
                T temp = this.storage[index - 1];
                this.index--;
                return temp;
            }
            else {
                throw new Exception("空");
            }
            
        }

        
       
    }
}
